package it.unive.taw;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ShowCookies2 extends HttpServlet {
  public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println(("<HTML><HEAD><TITLE>Lettura Cookie</TITLE></HEAD>" +
                "<BODY><H1>Lettura Cookie</H1>" +
                "<TABLE>\n" +
                "<TR>\n" +
                "  <TH>Nome</TH><TH>Valore</TH>"));
    Cookie[] cookies = request.getCookies();
    for(int i=0; i<cookies.length; i++)
      out.println("<TR><TD>" + cookies[i].getName() + "</TD><TD>" + cookies[i].getValue()+"</TD></TR>\n");
    out.println("</TABLE></BODY></HTML>");
  }
}
